package com.zhu.ttwords.model;

import com.zhu.ttwords.TTWORDS;
import com.zhu.ttwords.bean.UserBean;
import com.zhu.ttwords.common.DBTool;

import java.util.UUID;

/**
 * Created by KnightYe on 2015/4/8.
 */
public class RegisterModel implements IRegisterModel {
    @Override
    public long registUser(String username, String password) {
        long index;
        UserBean user = new UserBean();
        UUID uuid = UUID.randomUUID();
        user.setUid(uuid.toString());
        user.setTel(username);
        user.setPassword(password);
        index = DBTool.saveBeanData("TT_USER", "UID", user);
        if (index >= 0) {
            TTWORDS.getAppSetting().setUserId(user.getUid());
        }
        return index;
    }
}
